package algorithm;

public class leetcode_0074 {
    public boolean searchMatrix(int[][] matrix, int target) {
        int m=matrix.length;
        int n=matrix[0].length;
        return search(matrix,target,0,m*n,m,n);
    }
    public boolean search(int[][] matrix,int target,int left,int right,int m,int n){
        if(left>=right) return false;
        int mid=(left+right)/2;
        if(matrix[mid/n][mid%n]<target) return search(matrix,target,mid+1,right,m,n);
        else if(matrix[mid/n][mid%n]==target) return true;
        else return search(matrix,target,left,mid,m,n);
    }
}
